<template>
	<view class="box">
		<view class="">
			<u-tabs :list="list" active-color='#FA4528' :is-scroll="false" :current="current" @change="change"></u-tabs>
		</view>
		<view class="">
			<counp :icon='pic' :list='listCounps'></counp>
		</view>
		<shopro-empty v-if="!listCounps.length" :image="$IMG_URL + '/imgs/empty/empty_groupon.png'" tipText="暂无优惠券~"></shopro-empty>
	</view>

</template>
<script>
	import counp from '../user/components/sun-counp-item.vue'

	export default {
		components: {
			counp
		},
		data() {
			return {
				list: [{
					name: '可使用'
				}, {
					name: '失效券'
				}],
				current: 0,
				pic: [],
				listCounps: []
			}
		},
		onReachBottom() {
			console.log(222);
			this.getList()
		},
		mounted() {


			this.$http('common.getPic', {}).then(res => {
				if (res.code === 1) {
					this.pic = res.data.result.goodsInfoIcon
				}
			});
			this.getList()

		},
		methods: {
			change(index) {
				console.log(index);
				this.current = index;
				this.getList(index + 1)
			},
			getList(index) {
				// coupons
				this.$http('coupons.list', {
					type: index || 1
				}).then(res => {
					// console.log(res);
					if (res.code == 1) {
						this.listCounps = res.data
					}
				})

			}


		}
	}
</script>

<style scoped lang="scss">
	.box {
		min-height: 100vh;
		background-color: #f8f8f8;

	}
</style>
